package processor;

import model.FengxianTag;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.selector.Selectable;
import util.Mytime;

import java.util.List;

//import static processor.LoginProcessor.isRedirectedToLoginPage;

public class FenxiangPageProcessor {
    public static void processFirmFenxian(Page page){
        /**
         * @Description 获得风险信息
         * https://www.qichacha.com/firm_3c09b2c37cfd655f2030878a9f3e6fab.html#fengxian
         */
//        System.out.println("开始解析经营风险");
//        if(isRedirectedToLoginPage(page)){
//            return;
//        }
        List<Selectable> nodes = page.getHtml().xpath("//section[@class='panel b-a clear m_dataTab']//div//a").nodes();
        FengxianTag fengxianTag = new FengxianTag();
        fengxianTag.setCompany_unique(page.getRequest().getExtra("unique").toString());
        fengxianTag.setJingyingyichang(nodes.get(0).xpath("/a/allText()").toString());
        fengxianTag.setYangzhongweifa(nodes.get(1).xpath("/a/allText()").toString());
        fengxianTag.setGuquanchuzhi(nodes.get(2).xpath("/a/allText()").toString());
        fengxianTag.setXingzhengchufa(nodes.get(3).xpath("/a/allText()").toString());
        fengxianTag.setShuishouweifa(nodes.get(4).xpath("/a/allText()").toString());
        fengxianTag.setDongchandiya(nodes.get(5).xpath("/a/allText()").toString());
        fengxianTag.setHuanbaochufa(nodes.get(6).xpath("/a/allText()").toString());
        fengxianTag.setQingsuanxinxi(nodes.get(7).xpath("/a/allText()").toString());
        fengxianTag.setSifapaimai(nodes.get(8).xpath("/a/allText()").toString());
        fengxianTag.setTudizhiya(nodes.get(9).xpath("/a/allText()").toString());
        fengxianTag.setJianyizhuxiao(nodes.get(10).xpath("/a/allText()").toString());
        fengxianTag.setGongshicuigao(nodes.get(11).xpath("/a/allText()").toString());
        fengxianTag.setQianshuigonggao(nodes.get(12).xpath("/a/allText()").toString());
        fengxianTag.setCreatedTime(Mytime.getTime());
//        System.out.println("风险信息抓取完成");
        page.putField("FengxianTag", fengxianTag);
    }
}
